
// 单例模式基类
public class SingletonBase<T> where T : class, new()
{
    private static T instance;

    // 加锁，避免多线程问题，子类可用该锁对部分数据加锁
    protected static readonly object lockObj = new object();
    
    public static T Instance
    {
        get
        {
            lock (lockObj)
            {
                instance = instance ?? new T();
                return instance;
            }
        }
    }
}
